package com.challenger.utils;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * String工具类
 * 
 * @author 古振猛 404879269@qq.com
 *
 */
public class StringUtils {
	public static double getScore(String str) {
		String result = "";
		String[] temp = str.split("\\|");
		result = temp[0];
		return Double.parseDouble(result);
	}

	public static String getContent(String str) {
		String[] temp = str.split("\\|");
		if (temp.length > 1) {
			String content = temp[1];
			return content;
		} else {
			return "";
		}

	}

	public static List<Map<String, Object>> formatStudentProperty(String str) {
		// 分数
		double score = getScore(str);
		// 内容
		String content = getContent(str);
		// 结果
		List<Map<String, Object>> result = new ArrayList<Map<String, Object>>();
		// 添加分数score
		Map<String, Object> scoremap = new HashMap<String, Object>();
		scoremap.put("score", score);
		result.add(scoremap);
		// 添加内容content
		String cont[] = content.split(";");
		List<String> contetnList = new ArrayList<String>();
		System.out.println(cont.length);
		for (int i = 0; i < cont.length; i++) {
			contetnList.add(cont[i]);
		}
		Map<String, Object> contentMap = new HashMap<String, Object>();
		contentMap.put("content", contetnList);
		result.add(contentMap);
		return result;
	}

}
